﻿using Grow.ObjectMapper.CreateObjectMapper;

namespace Grow.ObjectMapper.Mapster.CreateObjectMapper
{
    public class CreateObjectMapperBuilder : ICreateObjectMapperBuilder
    {
        private readonly List<IObjectMapperMap> _objectMapperMaps;

        public CreateObjectMapperBuilder()
        {
            _objectMapperMaps = new();
        }

        public ICreateObjectMapperBuilder AddObjectMapperMap<TObjectMapperMap>() where TObjectMapperMap : IObjectMapperMap, new()
        {
            TObjectMapperMap objectMapperMap = new();
            if (!_objectMapperMaps.Contains(objectMapperMap))
            {
                _objectMapperMaps.Add(objectMapperMap);
            }
            return this;
        }

        public IEnumerable<IObjectMapperMap> GetObjectMapperMaps()
        {
            return _objectMapperMaps;
        }
    }
}
